package com.xyy.ec.pop.api.kingdinggmp.helpers;

import cn.hutool.core.map.MapUtil;
import com.xyy.ec.pop.api.kingdinggmp.dto.erp.ErpCustomerDto;
import com.xyy.ec.pop.api.kingdinggmp.dto.pop.PlatformCustomerDto;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class ErpHelper {
    public static List<ErpCustomerDto> popToErpCustomerConvert(List<PlatformCustomerDto> platformCustomerDtos, Map<String, String> customerCfgMap) {
        return platformCustomerDtos.stream().map(m -> {
            ErpCustomerDto erpCustomerDto = new ErpCustomerDto();
            erpCustomerDto.setFName(m.getCustomerName());
            erpCustomerDto.setFTEL(m.getPickPhone());
            erpCustomerDto.setFINVOICETITLE(m.getCustomerName());
            erpCustomerDto.setFTAXREGISTERCODE(m.getTaxpayerIdentity());
            erpCustomerDto.setFINVOICEBANKNAME(m.getRegisteredBank());
            erpCustomerDto.setFINVOICETEL(m.getPickPhone());
            erpCustomerDto.setFINVOICEBANKACCOUNT(m.getRegisteredBankAccount());
            erpCustomerDto.setFINVOICEADDRESS(m.getRegisteredAddress());
            erpCustomerDto.setFDescription("药帮忙自动推送" + m.getId());
            erpCustomerDto.setFSOCIALCRECODE(m.getTaxpayerIdentity());
            erpCustomerDto.setF_RPIH_lxr(m.getClientName());
            erpCustomerDto.setF_RPIH_shdz(m.getRegisteredAddress());
            erpCustomerDto.setFGroup(MapUtil.of("fnumber", customerCfgMap.get("FGroup")));
            return erpCustomerDto;
        }).collect(Collectors.toList());
    }
}
